/**
 * @addtogroup BLE_SRV BLE Services
 * @{
 * @brief Definitions and prototypes for the BLE Service interface.
 */

/**
 * @defgroup BLE_SDK_OTA OTA Service (OTAS)
 * @{
 * @brief Definitions and prototypes for the OTAS interface.
 *
 * @details The OTA Service exposes the state of a battery within a device.
 *          This module implements the Battery Service with the Battery Level
 *          characteristic. After @ref otas_init_t variable is initialized, the
 *          developer shall call @ref otas_service_init() to add the OTA
 *          Service and RX, TX, Control characteristic to the BLE stack database.
 *
 *          This module also provides \ref otas_notify_tx_data() function to the application
 *          to send data to peer. 
 */

#ifndef _LS_BLE_OTA_H_
#define _LS_BLE_OTA_H_

/*
 * INCLUDE FILES
 ****************************************************************************************
 */
#include "att.h"
#include "stdint.h"
#include "bcomdef.h"


/**
 * @defgroup OTAS_MACRO Defines
 * @{
 */
#define OTA_CONNECTION_MAX          1
#define OTA_MAX_DATA_LEN            20                                                  /**< Maximum length of OTA characteristic. */
/** @} */

/**
 * @defgroup OTA_ENUM Enumerations
 * @{
 */
/**@brief OTA Service event type. */
typedef enum
{
    OTA_EVT_INVALID,
    OTA_EVT_CONNECTED,
    OTA_EVT_DISCONNECT,
    OTA_EVT_CP_NOTIFICATION_ENABLED,
    OTA_EVT_CP_NOTIFICATION_DISABLED,
    OTA_EVT_CP_RECEIVE_DATA,
	OTA_EVT_PKT_RECEIVE_DATA,
    OTA_EVT_NOTIFY_COMPLETE,
} ota_evt_type_t;
/** @} */

/**
 * @defgroup OTA_STRUCT Structures
 * @{
 */
/**@brief OTA Service event. */
typedef struct
{
    ota_evt_type_t  evt_type;         /**< The OTAS event. */
    uint8_t         *p_data;          /**< Pointer to data. */
    uint16_t        length;           /**< Length of data. */
} ota_evt_t;
/** @} */

/**
 * @defgroup OTA_TYPEDEF Typedefs
 * @{
 */
/**@brief OTA Service event handler type. */
typedef void (*ota_evt_handler_t)(ota_evt_t *p_evt);

/**@brief OTA Service function type. */
typedef  void (*function)(void);
/** @} */

/**
 * @defgroup OTA_STRUCT Structures
 * @{
 */
/**@brief OTA Service initialization variable. */
typedef struct
{
    ota_evt_handler_t evt_handler;    /**< Handler to handle otas event. */
} ota_profile_cb_t;
/** @} */


/**
 * @defgroup OTA_FUNCTION Functions
 * @{
 */
/**
 *****************************************************************************************
 * @brief Add an OTA Service instance in the DB
 *
 * @param[in] p_ota_init :Pointer to OTA Service environment variable
 *
 * @return Result of service initialization.
 *****************************************************************************************
 */
int ota_service_init(ota_profile_cb_t *cb);

int ota_notify_tx_data(uint8_t *p_data, uint16_t length);

/** @} */

#endif
/** @} */
/** @} */
